package com.sxhalo.fsms.quartz;

public enum AlarmTripEnum {

	OverloadTrip(1,20, "过载跳闸"),  //8 OverloadAlarm
	StallTrip(2, 21,"堵转跳闸"),//9 StallAlarm
	BlockTrip(4, 22,"阻塞跳闸"), //10 BlockAlarm
	PhaseFailureTrip(8, 23,"断相跳闸"),//11 PhaseFailureAlarm
	NegativePhaseTrip(16,24, "反相序跳闸"),//12 NegativePhaseAlarm
	CurrentUnbalanceTrip(32,25, "电流不平衡跳闸"),//13 CurrentUnbalanceAlarm
	ExternalFaultTrip(64, 26,"外部故障跳闸"),//14 ExternalFaultAlarm
	PTCOverheatingTrip(128,27, "PTC过热跳闸"),//15 PTCOverheatingAlarm
	OvervoltageTrip(256, 28,"过电压跳闸"),//16 OvervoltageAlarm
	UndervoltageTrip(512,29, "欠电压跳闸"),//17 UndervoltageAlarm
	OverpowerTrip(1024, 30,"过功率跳闸"),//18 OverpowerAlarm
	UnderpowerTrip(2048, 31,"欠功率跳闸");//19 UnderpowerAlarm

	/**
	 * 报警码
	 */
	private final Integer code;
	/**
	 * 报警字段
	 */
	private final Integer attrId;

	/**
	 * 报警信息
	 */
	private final String msg;

	public Integer getCode() {
		return code;
	}
	public Integer getAttrId() {
		return attrId;
	}
	public String getMsg() {
		return msg;
	}

	AlarmTripEnum(Integer code, Integer attrId , String msg) {
		this.code = code;
		this.attrId = attrId;
		this.msg = msg;
	}

	/**
	 * 判断数值是否属于枚举类的值
	 * @param key
	 * @return
	 */
	public static boolean isInclude(int key){
		boolean include = false;
		for (AlarmTripEnum e: AlarmTripEnum.values()){
			if(e.getCode()==key){
				include = true;
				break;
			}
		}
		return include;
	}



	/**
	 * 获取某个枚举
	 * @param key
	 * @return
	 */
	public static AlarmTripEnum getEnumByKey(int key){
		for (AlarmTripEnum e: AlarmTripEnum.values()){
			if(e.getCode()==key){
				return e;
			}
		}
		return null;
	}
}